import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///左边文字 右边一个编辑框
class RowItem1 extends StatelessWidget {
  final String text;
  final TextStyle? textStyle;
  final double textFieldWidth;
  final String hintText;
  final TextStyle? hintStyle;
  final MainAxisAlignment mainAxisAlignment;
  final bool readOnly;
  final TextAlignVertical textAlignVertical;
  final InputBorder? inputBorder;

  RowItem1({
    this.text = "文字信息",
    this.textFieldWidth = 100,
    this.readOnly = true,
    this.textAlignVertical = TextAlignVertical.bottom,
    this.hintText = "hintText",
    this.hintStyle,
    this.mainAxisAlignment = MainAxisAlignment.spaceBetween,
    this.textStyle,
    this.inputBorder,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: this.mainAxisAlignment,
      children: [
        Text(
          this.text,
          style: this.textStyle == null
              ? TextStyle(fontWeight: FontWeight.bold, fontSize: 18.sp)
              : this.textStyle,
        ),
        Container(
          width: this.textFieldWidth,
          child: TextField(
            readOnly: this.readOnly,
            textAlignVertical: this.textAlignVertical,
            decoration: InputDecoration(
              border: this.inputBorder == null
                  ? OutlineInputBorder()
                  : this.inputBorder,
              hintText: this.hintText,
              hintStyle: this.hintStyle == null
                  ? TextStyle(fontSize: 18.sp)
                  : this.hintStyle,
            ),
          ),
        ),
      ],
    );
  }
}

///左边文字 右边一个Container
class RowItem2 extends StatelessWidget {
  final MainAxisAlignment mainAxisAlignment;
  final String text;
  final TextStyle? textStyle;
  final double width;
  final double height;
  final Decoration? decoration;
  final EdgeInsetsGeometry? padding;
  final Widget? child;

  const RowItem2(
      {Key? key,
      this.mainAxisAlignment = MainAxisAlignment.spaceBetween,
      this.text = "文字信息",
      this.textStyle,
      this.width = 100,
      this.height = 50,
      this.decoration,
      this.padding,
      this.child})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      Text(
        this.text,
        style: this.textStyle == null
            ? TextStyle(
                fontSize: 20.sp,
                fontWeight: FontWeight.bold,
              )
            : this.textStyle,
      ),
      Container(
        padding: this.padding == null ? EdgeInsets.all(20.w) : this.padding,
        width: this.width,
        height: this.height,
        decoration: this.decoration == null
            ? BoxDecoration(
                border: Border.all(color: Colors.grey, width: 2.w),
                borderRadius: BorderRadius.circular(12.w),
                color: Colors.white,
              )
            : this.decoration,
        child: this.child,
      ),
    ]);
  }
}
